﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
namespace vmlModel.Entities
{
    public class vmlShapeType : vmlPathShapeBase
    {
        //public string Path { get { return (vmlObjElement.Attribute("path") != null) ? vmlObjElement.Attribute("path").Value : ""; } }
        public bool NeedToAdjustFormulas { get; set; }
        public vmlShapeType()
        {

        }
        public vmlShapeType(XElement _vmlObjElement)
            : base(_vmlObjElement)
        {

        }
        public void RecalculateFormulas()
        {
            if(!NeedToAdjustFormulas) return ;
            Formulas = new List<vmlFormula>();
            foreach (XElement element in from elemnt in vmlObjElement.Elements()
                                         select elemnt)
            {
                switch (element.Name.LocalName.ToLower())
                {
                    case "formulas":
                        foreach (XElement formula in from f in element.Elements()
                                                     select f)
                        {
                            switch (formula.Name.LocalName.ToLower())
                            {
                                case "f":
                                    Formulas.Add(new vmlFormula(this, formula));
                                    break;
                                default:
                                    break;
                            }
                        }
                        break;
                    default:
                        break;
                }
            }
        }

    }
}
